/**
 * 
 */
package uy.com.pzit.fpmundialmodel.manager;

import java.util.ArrayList;
import java.util.HashSet;

import org.springframework.beans.factory.annotation.Autowired;

import uy.com.pzit.fpmundialmodel.dao.BomboDAO;
import uy.com.pzit.fpmundialmodel.domain.Bombo;
import uy.com.pzit.fpmundialmodel.domain.Mundial;
import uy.com.pzit.fpmundialmodel.generator.BomboGenerator;

/**
 * @author pferraz
 *
 */
public class BomboManager {

	@Autowired
	private BomboDAO bomboDAO;
	
	public void generateBombos(Mundial mundial) {
		mundial.setBombos(new HashSet<>(BomboGenerator.generate(new ArrayList<>(mundial.getEliminatorias()), mundial.getLocalidad())));
		for(Bombo b:mundial.getBombos()){
			 bomboDAO.addBombo(b);//FIJARSE SI EN EL MUNDIAL LE QUEDA EL MISMO ID DE BOMBO QUE LA BASE
		}
	}

	/**
	 * @param bomboDAO the bomboDAO to set
	 */
	public void setBomboDAO(BomboDAO bomboDAO) {
		this.bomboDAO = bomboDAO;
	}

	

}
